﻿Class FontDialogWindow

    Private ViewModel As New ViewModel.FontDialogWindowViewModel


    Public Property SelectedFontFamily() As FontFamily
        Get
            Return ViewModel.SelectedFontFamily
        End Get
        Set(ByVal value As FontFamily)

            For Each ff In ViewModel.FontFamilies
                For Each fname In ff.FontFamily.FamilyNames.Values
                    For Each valueName In value.FamilyNames.Values
                        If fname = valueName Then
                            ViewModel.FontFamiliesView.MoveCurrentTo(ff)
                            Exit Property
                        End If
                    Next
                Next
            Next
        End Set
    End Property

    Public Property SelectedFontSize() As Double
        Get
            Return ViewModel.SelectedFontSize
        End Get
        Set(ByVal value As Double)
            ViewModel.FontSizesView.MoveCurrentTo(value)
        End Set
    End Property

    Public Sub New()

        ' この呼び出しは、Windows フォーム デザイナで必要です。
        InitializeComponent()

        ' InitializeComponent() 呼び出しの後で初期化を追加します。
        Me.DataContext = ViewModel

        SelectedFontFamily = Me.FontFamily
        SelectedFontSize = Me.FontSize

    End Sub

    Private Sub OkButton_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
        Me.DialogResult = True
        Me.Close()
    End Sub

    Private Sub CancelButton_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
        Me.DialogResult = False
        Me.Close()
    End Sub
End Class
